 begintownscript;
variables;
short choice,i,j,level;

body;
beginstate init_state;
i = 0;
while(char_ok(i) == 0){
	i = i + 1;
}
if(get_flag(26,0) == 0){
	set_ticks_forward(0 - get_current_tick());
	relocate_character(i,27,27);
	force_view_center(27,27);
	set_character_facing(i,0);
	set_character_pose(i,0);
	force_instant_terrain_redraw();
	
	//Priestess
level = get_level(i);
set_level(i,12);
while(level > 1){
	change_char_xp(i,-25 * 100);
	level = level - 1;
}
level = 12;
while(level > 1){
	change_char_xp(i,500);
	change_char_xp(i,500);
	level = level - 1;
}
j = 0;
while(j <= 19){
	if(get_spell_level(i,0,j) > 0)
		change_spell_level(i,0,j,-1* get_spell_level(i,0,j));
	if(get_spell_level(i,1,j) > 0)
		change_spell_level(i,1,j,-1 * get_spell_level(i,1,j));
	j = j + 1;
}
j = 0;
while(j <= 22){
	set_char_trait(i,j,0);
	j = j + 1;
}
change_pc_skill_pts(i,-1 * (get_char_skill_pts(i)));
alter_stat(i,0,4 - get_stat(i,0)); //- Strength
alter_stat(i,0,4 - get_stat(i,0)); //- Strength
alter_stat(i,1,5 - get_stat(i,1)); // - Dexterity
alter_stat(i,1,5 - get_stat(i,1)); // - Dexterity
alter_stat(i,2,7 - get_stat(i,2)); // - Intelligence
alter_stat(i,2,7 - get_stat(i,2)); // - Intelligence
alter_stat(i,3,6 - get_stat(i,3)); // - Endurance
alter_stat(i,3,6 - get_stat(i,3)); // - Endurance
alter_stat(i,4,3 - get_stat(i,4)); // - Melee Weapons
alter_stat(i,5,0 - get_stat(i,5)); // - Pole Weapons
alter_stat(i,6,0 - get_stat(i,6)); // - Bows
alter_stat(i,7,0 - get_stat(i,7)); // - Thrown Missiles
alter_stat(i,8,0 - get_stat(i,8)); // - Hardiness
alter_stat(i,9,0 - get_stat(i,9)); // - Defense
alter_stat(i,10,0 - get_stat(i,10)); // - Assassination
alter_stat(i,11,0 - get_stat(i,11)); // - Mage Spells
alter_stat(i,12,6 - get_stat(i,12)); // - Priest Spells
alter_stat(i,13,0 - get_stat(i,13)); // - Arcane Lore
alter_stat(i,14,5 - get_stat(i,14)); // - Potion Making
alter_stat(i,15,0 - get_stat(i,15)); // - Tool Use
alter_stat(i,16,0 - get_stat(i,16)); // - Nature Lore
alter_stat(i,17,8 - get_stat(i,17)); // - First Aid
alter_stat(i,18,0 - get_stat(i,18)); // - Luck
alter_stat(i,19,3 - get_stat(i,19)); // - Quick Strike
alter_stat(i,20,0 - get_stat(i,20)); // - Parry
alter_stat(i,21,0 - get_stat(i,21)); // - Blademaster
alter_stat(i,22,0 - get_stat(i,22)); // - Anatomy
alter_stat(i,23,0 - get_stat(i,23)); // - Gymnastics
alter_stat(i,24,0 - get_stat(i,24)); // - Pathfinder
alter_stat(i,25,0 - get_stat(i,25)); // - Magery
alter_stat(i,26,0 - get_stat(i,26)); // - Resistance
alter_stat(i,27,0 - get_stat(i,27)); // - Magical Efficiency
alter_stat(i,28,0 - get_stat(i,28)); // - Lethal Blow
alter_stat(i,29,5 - get_stat(i,29)); // - Riposte
alter_stat(i,30,0 - get_stat(i,30)); // - Sharpshooter
change_spell_level(i,1,0,3);
change_spell_level(i,1,1,4);
change_spell_level(i,1,2,2);
//change_spell_level(i,1,3,3);


pay_coins(coins_amount());
set_name(i,"Priestess");
reward_give(111);
reward_give(18);
reward_give(240);
reward_give(220);
reward_give(462);
change_char_energy(i,999);
change_char_health(i,-999);
change_char_health(i,999);
revive_party();

level = 0;
while(level <= 63){
	print_str(" ");
	level = level + 1;
}
print_str_color("Now entering: The Priestess's Tale",3);
}
else{
	j = 6;
	while(j <= 119){
		erase_char(j);
		j = j + 1;
	}
}
break;

beginstate exit_state;
break;

beginstate start_state;
if(get_flag(25,0) == 1)
	message_dialog("We'd gathered in the Sanctum for morning prayer. Prayer came first every morning at dawn. Father Kay used to say that if we began our day with our minds in the proper state, we'd end the day the same.","That morning, though, I was concentrating less on meditation than on the chores that would take the rest of my morning. I knew it was selfish of me, but I was already tired and the prospect of hard work galled me.");
if(get_flag(25,0) == 2)
	message_dialog("Some of the nearby villagers had taken time from their daily routines to attend as well. Some of them were under the care of the Order, but others had left their fields and animals to come here.","I recited the meditations by rote, and allowed my eyes and mind to drift about the room. They landed on the star emblem above the altar and fixed there.");
if(get_flag(25,0) == 3){
	reset_dialog();
	add_dialog_str(0,"The seven-pointed star was the emblem of the Order of Virtues. It hung proudly on the wall of the Chapel of Compassion, reminding us all of the virtues we were to strive to exhibit in our every day lives.",0);
	add_dialog_str(1,"But nobody ever did. That's what never made sense to me. The virtues were a way to improve the world, but I'd been at the Chapel for eight years and things hadn't gotten any better.",0);
	add_dialog_str(2,"Once when I was a child I asked Father Kay why, if the virtues were the way to a better world, so many people ignored them.",0);
	add_dialog_str(3,"He told me that many people only knew how to find happiness by putting themselves first, but by our example they would see that you could find happiness through others. Compassion was a hard thing to teach-- we just had to be patient.",0);
	add_dialog_str(4,"Even then I wasn't so sure. Perhaps we were the ones with the wrong idea, and the thieves and criminals were just waiting for us to come to our senses.",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
}
if(get_flag(25,0) == 4){
	message_dialog("Suddenly I realized that I was the only one still reciting the prayers. I halted, and glanced about to make sure nobody had noticed.","Brother Eustace and the villager immediately to my left were looking at me oddly, but nobody else had taken note. They were all distracted by Brother Matthias, who'd just interrupted service and was speaking to Father Kay.");
	message_dialog("_Father, there's a man at the door. Well, at the door step really, but he's here and... Well you should see for yourself Father, he's in a bad way and I think he needs care._","");
	message_dialog("_If he is in need of aid, brother, then he doesn't belong out on the doorstep. Have you brought him inside?_","");
	message_dialog("_No, Father, I'm sorry but I haven't. You see, he's.... well you should come see for yourself. I wouldn't presume to bring him in here without your permission._","");
	message_dialog("_You know we take any man here, brother, but no matter. Lead me to him._","");
	erase_char(7);
	message_dialog("Father Kay strode out of the room, Matthias leading the way. After a moment, the rest of the congregation followed behind.","");
	j = 6;
	while(j <= 119){
		if(char_ok(j) == 1)
			erase_char(j);
		j = j + 1;
	}
}
if(get_flag(25,0) < 5)
	inc_flag(25,0,1);
if((get_flag(25,2) == 1) && (get_flag(25,1) == 1)){
	set_flag(25,1,2);
	relocate_character(i,0,0);
	force_view_center(0,0);
	set_character_pose(i,14);
	force_instant_terrain_redraw();
	message_dialog("I sagged back in the pew and allowed my eyes to close. All the stress, anxiety, and anger had seeped away and exhaustion rushed in to take their place.","For the first time in a what seemed like ages-- since Logan left I suppose-- I sank into a deep sleep."); 
	pause(5);
	play_sound(96);
	pause(5);
	message_dialog("I woke with a start. I was unsure what it was that had disturbed my slumber, but a feeling of uneasiness had come over me.","I climbed to my feet and gasped in pain from the cricks in my back. Have you ever slept on a wooden pew? Well I don't advise you to try.");
	set_character_pose(i,0);
	relocate_character(i,22,27);
	force_view_center(22,27);
	force_instant_terrain_redraw();
}
break;

beginstate 10;
if(get_flag(26,0) > 0){
	block_entry(1);
	message_dialog("I still had a lot to think about, and the silent inner sanctum was as good a place as any to sort things out.","");
	end();
}
move_to_new_town(26,22,30);
break;

beginstate 11;
if((get_flag(26,0) > 0) && (get_flag(25,1) == 0)){
	block_entry(1);
	set_flag(25,1,1);
	relocate_character(i,22,27);
	force_view_center(22,27);
	force_instant_terrain_redraw();
	pause(2);
	message_dialog("To tell the truth, I never spent much time in the Inner Sanctum. I mean I always attended services, but I just didn't spend much time there on my own.","It wasn't that I didn't like the religious side of the Order-- it just didn't make much sense to me when Father Kay wasn't there to guide. It was all fine at prayer service, but on my own it was-- well... awkward.");
	message_dialog("I knelt, but my mind wasn't on prayer. I was looking for silence, and I'd found it.","My eyes landed on the star above the altar yet again. It was placed there for just that reason, so that it would command attention. It was a simple thing. But what it stood for was anything but simple.");
	message_dialog("Do unto others as you'd have them do unto you. Compassion is so black and white.","But what if it isn't.....");
	play_sound(58);
	activate_hidden_group(1);
	force_instant_terrain_redraw();
	pause(3);
	set_char_dialogue_pic(20,306,0);
	relocate_character(20,23,27);
	force_instant_terrain_redraw();
	pause(3);
	message_dialog("Father Kay approached to kneel beside me. I didn't say anything, though it was clear that he'd come to speak with me.","I was ashamed to realize that I was actually angry with him.");
}
break;

beginstate 12;
if(get_flag(25,1) == 2){
	set_flag(25,1,3);
	message_dialog("I walked down the aisle towards the doors. I'd convinced myself that nothing was the matter. There was no reason to worry.","Yet the feeling of uneasiness persisted.");
}
break;

beginstate 13;
if(get_flag(25,1) == 3){
	set_flag(25,1,4);
	reset_dialog();
	add_dialog_str(0,"There was a row of tall windows above the double doors that led out of the inner sanctum. They provided a view of the second floor of the chapel above.",0);
	add_dialog_str(1,"Something in the corner of my eye caught my attention and I glanced up. There was a man there-- I just got a glimpse of him but I could tell he was no monk. He was tall and sinister and strode with a purpose.",0);
	add_dialog_str(2,"He wore a dark tunic made of an unfamiliar material, and a midnight-black cloak swirled behind him. It seemed to suck up all the light around him, leaving a trail of darkness as it passed and obscuring any details about the man himself.",0);
	add_dialog_str(3,"My heart was in my throat. I stood frozen for an instant, and then slowly walked forward as if coming out of a trance before breaking into a headlong sprint towards the doors.",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
	move_to_new_town(26,22,30);
} 
break;

beginstate 100;
block_entry(1);
break;

beginstate 101;
if((get_flag(26,0) > 0) && (get_flag(25,1) == 1))
	block_entry(1);
break;